import { FormSchema } from '@/components/Form/index';
import { BasicColumn } from '@/components/Table/src/types/table';

export interface ListItem {
  key?: string;
  title: string;
  description: string;
  extra?: string;
  avatar?: string;
  color?: string;
}

// tab的list
export const settingList = [
  {
    key: '1',
    name: '系统设置',
    component: 'BaseSetting',
  },
  {
    key: '2',
    name: '短信配置',
    component: 'SmsSetting',
  },
  {
    key: '3',
    name: '扩展配置',
    component: 'ExpdSetting',
  },
];

// 基础设置 form
export const baseSetschemas: FormSchema[] = [
  {
    field: 'station_open',
    component: 'Switch',
    label: '站点开启',
    helpMessage: '站点开始|关闭（用于升级等临时关闭），关闭后前端会弹窗显示站点升级中，请稍后访问!',
    colProps: {
      span: 18,
    },
    componentProps: {
      checkedChildren: '开启',
      unCheckedChildren: '关闭',
    },
  },
  {
    field: 'site_name',
    component: 'Input',
    label: '网站名称',
    helpMessage: '网站名称很多地方会显示，建议认真填写!',
    colProps: { span: 18 },
    componentProps: {
      placeholder: '请输入网站名称',
    },
    ifShow: ({ values }) => {
      return !!values.station_open;
    },
  },
  {
    field: 'site_url',
    component: 'Input',
    label: '网站地址',
    helpMessage:
      '安装自动配置，不要轻易修改，更换会影响网站访问、接口请求、本地文件储存、支付回调、微信授权、支付、小程序图片访问、部分二维码、官方授权等',
    colProps: { span: 18 },
    componentProps: {
      placeholder: '请输入网站地址',
    },
    ifShow: ({ values }) => {
      return !!values.station_open;
    },
  },
  {
    field: 'icp_record_No',
    component: 'Input',
    label: 'ICP备案号',
    colProps: { span: 18 },
    helpMessage: '网站的备案号',
    componentProps: {
      placeholder: '请输入ICP备案号',
    },
    ifShow: ({ values }) => {
      return !!values.station_open;
    },
  },
  {
    field: 'icp_url',
    component: 'Input',
    label: 'ICP备案链接',
    colProps: { span: 18 },
    helpMessage: '备案号点击跳转的链接',
    componentProps: {
      placeholder: '请输入ICP备案链接',
    },
    ifShow: ({ values }) => {
      return !!values.station_open;
    },
  },
  {
    field: 'network_security',
    component: 'Input',
    label: '网安备案',
    colProps: { span: 18 },
    helpMessage: '公安部门登记的备案信息',
    componentProps: {
      placeholder: '请输入网安备案',
    },
    ifShow: ({ values }) => {
      return !!values.station_open;
    },
  },
  {
    field: 'network_security_url',
    component: 'Input',
    label: '网安备案链接',
    colProps: { span: 18 },
    helpMessage: '网安备案号点击跳转的链接',
    componentProps: {
      placeholder: '请输入网安备案链接',
    },
    ifShow: ({ values }) => {
      return !!values.station_open;
    },
  },
  {
    field: 'tengxun_map_key',
    component: 'Input',
    label: '腾讯地图KEY',
    helpMessage: '腾讯地图KEY，申请地址：https://lbs.qq.com',
    colProps: { span: 18 },
    componentProps: {
      placeholder: '请输入腾讯地图KEY',
    },
    ifShow: ({ values }) => {
      return !!values.station_open;
    },
  },
  {
    field: 'statistic_script',
    component: 'InputTextArea',
    label: '统计代码',
    colProps: { span: 18 },
    helpMessage: '程序访问统计代码，填写script标签内的内容',
    componentProps: {
      placeholder: '程序访问统计代码，填写script标签内的内容',
      rows: 6,
    },
    ifShow: ({ values }) => {
      return !!values.station_open;
    },
  },
];

// 短信配置 form
export const smsSetschemas: FormSchema[] = [
  {
    field: 'open_sms',
    component: 'Switch',
    label: '短信开关',
    helpMessage: '关闭后用户无法收到短信，但日志中将记录',
    colProps: {
      span: 18,
    },
    componentProps: {
      checkedChildren: '开启',
      unCheckedChildren: '关闭',
    },
  },
  {
    field: 'sms_app_key',
    component: 'Input',
    label: 'appKey',
    helpMessage: '短信应用的AppKey',
    colProps: { span: 18 },
    componentProps: {
      placeholder: '请输入appKey',
    },
    ifShow: ({ values }) => {
      return !!values.open_sms;
    },
  },
  {
    field: 'sms_app_secret',
    component: 'Input',
    label: 'secretKey',
    helpMessage: '短信应用的AppSecret',
    colProps: { span: 18 },
    componentProps: {
      placeholder: '请输入secretKey',
    },
    ifShow: ({ values }) => {
      return !!values.open_sms;
    },
  },
];

// 扩展配置 list
export const columns: BasicColumn[] = [
  {
    title: 'ID',
    dataIndex: 'id',
    width: 150,
    editRow: false,
    defaultHidden: true,
  },
  {
    title: '配置名称',
    dataIndex: 'title',
    width: 150,
    editRow: true,
    editRule: true,
  },
  {
    title: 'KEY',
    dataIndex: 'menu_name',
    width: 150,
    align: 'left',
    editRow: true,
    editRule: true,
  },
  {
    title: 'VALUE',
    width: 350,
    dataIndex: 'value',
    align: 'left',
    editRow: true,
    editRule: true,
  },
  {
    title: '排序',
    dataIndex: 'sort',
    editRow: true,
    editComponent: 'InputNumber',
    width: 100,
    editComponentProps: () => {
      return {
        min: 0,
      };
    },
  },
  {
    title: '状态',
    dataIndex: 'status',
    editRow: true,
    editComponent: 'Switch',
    editValueMap: (value) => {
      return value ? '开' : '关';
    },
    width: 100,
  },
  {
    title: '备注',
    dataIndex: 'remarks',
    align: 'left',
    width: 350,
    editRow: true,
  },
  {
    title: '更新时间',
    dataIndex: 'updatetime',
    width: 150,
    editRow: false,
  },
];
